<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p><strong>flexmark-java extension for enumerated reference processing</strong></p>
<p>To create an element anchor or bookmark use the id attribute syntax of <code>{#type:reference}</code> after
the element to be referenced. Where <code>type</code> is a category used to keep separate numbering within
the category and <code>reference</code> is used to uniquely identify an element in the category. The anchor
id of the element will be <code>type:reference</code> and this must be used by the enumerated reference
label or link.</p>
<p><img src="information_source.png" alt="emoji symbols:information_source" height="20" width="20"> <code>type</code> must not start with a digit.</p>
<p>To refer to the element in the document use the enumerated reference elements:</p>
<ol>
  <li>
    <p>A reference link syntax <code>[@type:reference]</code> converts to a link based on type pattern defined
    in enumerated reference format definition. The target of the link will be an element with a
    <code>{#type:reference}</code> attribute assigned to it. The text of the link will be that which is
    defined by the enumerated reference definition for <code>type</code>.</p>
  </li>
  <li>
    <p>A reference text syntax <code>[#type:reference]</code> converts to text which is defined by the
    enumerated reference definition for <code>type</code>. This is to be used where the identifying text of
    the element within the document is needed.</p>
  </li>
  <li>
    <p>One reference definition for each <code>type</code> must be included in the document. Syntax <code>[@type]: Label Text [#]</code> is used to define how to create a label for all elements of the given <code>type</code>.
    This usually includes the ordinal position of the element in the document.</p>
    <p>Text <strong>following</strong> the <code>[@type]:</code> is used as the label with the <code>[@] or [#]</code> replaced by the
    ordinal number of the element in the document relative to other elements of the same <code>type</code>.
    The first element will have ordinal of 1, second 2, etc.</p>
    <p>If a type has no enumerated definition then <code>type [#]</code> will be used where <code>type</code> is the
    category type and <code>[#]</code> is the ordinal of the element in its category. It is equivalent to
    specifying <code>[@type]: type [#]</code> in the document.</p>
  </li>
</ol>
<p>For example:</p>
<pre><code>![Flexmark Icon Logo](https://github.com/vsch/flexmark-java/raw/master/assets/images/flexmark-icon-logo%402x.png){#fig:test}   
[#fig:test]

![Flexmark Icon Logo](https://github.com/vsch/flexmark-java/raw/master/assets/images/flexmark-icon-logo%402x.png){#fig:test2}   
[#fig:test2]

| heading | heading | heading |
|---------|---------|---------|
| data    | data    |         |
[[#tbl:test] caption]
{#tbl:test}

See [@fig:test2]

See [@fig:test]

See [@tbl:test]

[@tbl]: Table [#].

[@fig]: Figure [#].
</code></pre>
<p>is equivalent to the following without having to manually keep track of numbering of individual
elements:</p>
<pre><code>![Flexmark Icon Logo](https://github.com/vsch/flexmark-java/raw/master/assets/images/flexmark-icon-logo%402x.png){#fig:test}  
Figure 1.

![Flexmark Icon Logo](https://github.com/vsch/flexmark-java/raw/master/assets/images/flexmark-icon-logo%402x.png){#fig:test2}  
Figure 2.

| table |
|-------|
| data  |
[Table 1. caption]
{#tbl:test}

See [Figure 2.](#fig:test2)

See [Figure 1.](#fig:test)

See [Table 1.](#tbl:test)

</code></pre>
<p>Will render as:</p>
<pre><code>&lt;p&gt;&lt;img src=&quot;https://github.com/vsch/flexmark-java/raw/master/assets/images/flexmark-icon-logo%402x.png&quot; id=&quot;fig:test&quot; /&gt;&lt;br /&gt;
&lt;span&gt;Figure 1.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://github.com/vsch/flexmark-java/raw/master/assets/images/flexmark-icon-logo%402x.png&quot; alt=&quot;Fig&quot; id=&quot;fig:test2&quot; /&gt;&lt;br /&gt;
&lt;span&gt;Figure 2.&lt;/span&gt;&lt;/p&gt;
&lt;table id=&quot;tbl:test&quot;&gt;
  &lt;thead&gt;
    &lt;tr&gt;&lt;th&gt;table&lt;/th&gt;&lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;&lt;td&gt;data&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;caption&gt;&lt;span&gt;Table 1.&lt;/span&gt; caption&lt;/caption&gt;
&lt;/table&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a href=&quot;#fig:test2&quot;&gt;&lt;span&gt;Figure 2.&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a href=&quot;#fig:test&quot;&gt;&lt;span&gt;Figure 1.&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a href=&quot;#tbl:test&quot;&gt;&lt;span&gt;Table 1.&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
</code></pre>
<h2 id="enumerated-reference-text-in-headings">Enumerated Reference Text in Headings</h2>
<p>Because headings contain their own anchor id an enumerated reference with only a <code>type</code> is
allowed in headings and has the effect of adding an incremented counter to heading text.</p>
<pre><code class="markdown"># [#hd1] Heading 1

# [#hd1] Heading 2

# [#hd1] Heading 3

[@hd1]: [#].
</code></pre>
<p>Will render as:</p>
<pre><code class="html">&lt;h1&gt;1. Heading 1&lt;/h1&gt;
&lt;h1&gt;2. Heading 2&lt;/h1&gt;
&lt;h1&gt;3. Heading 3&lt;/h1&gt;
</code></pre>
<h2 id="compound-types">Compound Types</h2>
<p>Compound enumerated reference types are created by including more than one type reference with
<code>:</code> separating each type.</p>
<p>The effect of compound reference is that all child reference counters are reset to 1 for change
in parent type&rsquo;s ordinal allowing creation of legal numbering using enumerated references.</p>
<p><img src="information_source.png" alt="emoji symbols:information_source" height="20" width="20"> When combining enumerated type ordinal strings for compound enumerated
reference if the last element of the enumerated format definition is an empty enumerated
reference text <code>[#]</code> or empty enumerated reference link <code>[@]</code> then a <code>.</code> will be added after the
parent enumerated ordinal text.</p>
<p><img src="information_source.png" alt="emoji symbols:information_source" height="20" width="20"> For compound type for headings without an element id, a trailing <code>:</code> is
needed to prevent the last <code>type</code> from being interpreted as the element id.</p>
<pre><code class="markdown"># [#hd1] Heading 1

## [#hd1:hd2:] Heading 1.1

### [#hd1:hd2:hd3:] Heading 1.1.1

### [#hd1:hd2:hd3:] Heading 1.1.2

## [#hd1:hd2:] Heading 1.2

### [#hd1:hd2:hd3:] Heading 1.2.1

### [#hd1:hd2:hd3:] Heading 1.2.2

# [#hd1] Heading 2

## [#hd1:hd2:] Heading 2.1

### [#hd1:hd2:hd3:] Heading 2.1.1

### [#hd1:hd2:hd3:] Heading 2.1.2

[@hd1]: [#].
[@hd2]: [#].
[@hd2]: [#].
</code></pre>
<p>Will render as:</p>
<pre><code class="html">&lt;h1&gt;1. Heading 1&lt;/h1&gt;
&lt;h2&gt;1.1. Heading 1.1&lt;/h2&gt;
&lt;h3&gt;1.1.1. Heading 1.1.1&lt;/h3&gt;
&lt;h3&gt;1.1.2. Heading 1.1.2&lt;/h3&gt;
&lt;h2&gt;1.2. Heading 1.2&lt;/h2&gt;
&lt;h3&gt;1.2.1. Heading 1.2.1&lt;/h3&gt;
&lt;h3&gt;1.2.2. Heading 1.2.2&lt;/h3&gt;
&lt;h1&gt;2. Heading 2&lt;/h1&gt;
&lt;h2&gt;2.1. Heading 2.1&lt;/h2&gt;
&lt;h3&gt;2.1.1. Heading 2.1.1&lt;/h3&gt;
&lt;h3&gt;2.1.2. Heading 2.1.2&lt;/h3&gt;
</code></pre>
</body>
</html>
